package org.minproject.my_library_back.controller;

import jakarta.annotation.Resource;
import org.minproject.my_library_back.common.CommonResponse;
import org.minproject.my_library_back.domain.Buy;
import org.minproject.my_library_back.service.BuyService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class BuyController {
    @Resource
    private BuyService buyService;

    @GetMapping("/buys")
    public CommonResponse<List<Buy>> getBuys() throws Exception {
        return buyService.getBuys();
    }

    @GetMapping("/buys/{user_id}")
    public CommonResponse<List<Buy>> getBuysByUserid(@PathVariable("user_id") int userid) throws Exception {
        return buyService.getBuysByUserid(userid);
    }
}
